import com.project.srtp.secure.model.ComplexDfa;
import com.project.srtp.secure.model.DfaTransition;

/**
 * @author 曹行阳
 * @version 0.1
 * @date 2025/6/17 18:54
 */
public class DfaPrinter {
    public static void printMermaid(ComplexDfa dfa) {
        System.out.println("```mermaid");
        System.out.println("stateDiagram-v2");
        System.out.println("    [*] --> " + dfa.getInitialState());

        for (DfaTransition t : dfa.getTransitions()) {
            System.out.printf("    %s --> %s : %s%n", t.getFromState(), t.getToState(), t.getInputSymbol());
        }

        for (String v : dfa.getViolationStates()) {
            System.out.printf("    state %s <<violation>>%n", v);
        }

        String accept = dfa.getMetadata().get("acceptState");
        if (accept != null) {
            System.out.printf("    state %s <<accept>>%n", accept);
        }

        System.out.println("```");
    }
}
